home *** CD-ROM | disk | FTP | other *** search
- <?php
-
- $id=$_GET["id"];
-
- include_once("fn.php");
- $ip=FetchIP();
- $ipok=IPisOK($ip);
-
- if ((strcmp($_POST["Person"],"")!=0 || strcmp($_POST["Comment"],"")!=0) && $ipok)
- {
-
- $soubor="text/%num%.cmt";
- $soubor=str_replace("%num%",$id,$soubor);
-
- $cmtmsk = "<COMMENT PERSON=\"%Person%\" MAIL=\"%Mail%\" WEB=\"%Web%\" TEXT=\"%Text%\" TIME=\"%time%\" IP=\"%ip%\" />\n";
-
-
- $outf="text/out%num%.txt";
- $outf=str_replace("%num%",$id,$outf);
-
- $out = fopen($outf, "w");
- $time=time();
-
- $person_in=$_POST["Person"];
- $mail_in=$_POST["Mail"];
- $web_in=$_POST["Web"];
- $comment_in=$_POST["Comment"];
-
- ${STRIPTAGSDISABLER}
- {
- $person_in=strip_tags($person_in);
- $mail_in=strip_tags($mail_in);
- $web_in=strip_tags($web_in);
- $comment_in=strip_tags($comment_in);
- }
-
- function startElement($parser, $name, $attrs)
- {
- if (strcmp($name,"COMMENTS")==0)
- {
- global $cmtmsk;
- global $out;
- global $time;
- global $ip;
- global $person_in;
- global $mail_in;
- global $web_in;
- global $comment_in;
- $cmtsmsk="<COMMENTS Count=\"%count%\">\n";
- $cmtsmsk=str_replace("%count%",((int)$attrs['COUNT'])+1,$cmtsmsk);
- fwrite($out, $cmtsmsk);
- $res=str_replace("%Person%",makeXMLcompatible(charEncode($person_in)),$cmtmsk);
- $res=str_replace("%Mail%",makeXMLcompatible(charEncode($mail_in)),$res);
- $res=str_replace("%Web%",makeXMLcompatible(charEncode($web_in)),$res);
- $res=str_replace("%Text%",makeXMLcompatible(charEncode($comment_in)),$res);
- $res=str_replace("%time%",$time,$res);
- $res=str_replace("%ip%",$ip,$res);
- fwrite($out, $res);
- }
-
- if (strcmp($name,"COMMENT")==0)
- {
- global $cmtmsk;
- global $out;
- $res=str_replace("%Person%",makeXMLcompatible($attrs['PERSON']),$cmtmsk);
- $res=str_replace("%Mail%",makeXMLcompatible($attrs['MAIL']),$res);
- $res=str_replace("%Web%",makeXMLcompatible($attrs['WEB']),$res);
- $res=str_replace("%Text%",makeXMLcompatible($attrs['TEXT']),$res);
- $res=str_replace("%time%",makeXMLcompatible($attrs['TIME']),$res);
- $res=str_replace("%ip%",makeXMLcompatible($attrs['IP']),$res);
- fwrite($out, $res);
- }
- }
-
- function endElement($parser, $name)
- {
- if (strcmp($name,"COMMENTS")==0)
- {
- global $out;
- fwrite($out, "</COMMENTS>");
- }
- }
-
- if (file_exists($soubor))
- {
- $xml_parser = xml_parser_create();
- xml_set_element_handler($xml_parser, "startElement", "endElement");
- if (!($fp = fopen($soubor, "r"))) {
- die("could not open XML input");
- }
-
-
- fwrite($out, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
-
- while ($xmldata = fread($fp, 4096)) {
- if (!xml_parse($xml_parser, $xmldata, feof($fp))) {
- die(sprintf("XML error: %s at line %d",
- xml_error_string(xml_get_error_code($xml_parser)),
- xml_get_current_line_number($xml_parser)));
- }
- }
- xml_parser_free($xml_parser);
- fclose($fp);
- }
- else
- {
- fwrite($out, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
- fwrite($out, "<COMMENTS Count=\"1\">");
- $res=str_replace("%Person%",makeXMLcompatible(charEncode($person_in)),$cmtmsk);
- $res=str_replace("%Mail%",makeXMLcompatible(charEncode($mail_in)),$res);
- $res=str_replace("%Web%",makeXMLcompatible(charEncode($web_in)),$res);
- $res=str_replace("%Text%",makeXMLcompatible(charEncode($comment_in)),$res);
- $res=str_replace("%time%",$time,$res);
- $res=str_replace("%ip%",FetchIP(),$res);
- fwrite($out, $res);
- fwrite($out, "</COMMENTS>");
- }
-
- fclose($out);
- copy($outf,$soubor);
- unlink($outf);
-
- // handle rss stuff
- //include_once("cmtrss.php");
- //UpdateCommentRSS(makeXMLcompatible(charEncode($_POST["Person"])),makeXMLcompatible(charEncode($_POST["Comment"])),$time,$id);
- //
- ${EMAILNOTIFICATION}
-
- }
- if ($ipok)
- {
- $refr="<meta http-equiv=\"refresh\" content=\"0; url=%id%.php\">";
- $refr=str_replace("%id%",$id,$refr);
- echo $refr;
- }
- else
- echo "Zakázáno";
-
- ?>
-